package com.combetter.changxing.ui.activity;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.combetter.changxing.R;
import com.combetter.changxing.databinding.ActivityRegisterBinding;
import com.combetter.changxing.ui.base.BaseActivity;
import com.combetter.changxing.ui.fragment.RegisterFragment;
import com.combetter.changxing.util.Check;
import com.combetter.changxing.util.LogUtil;
import com.combetter.changxing.viewmodel.RegisterViewModel;

/**
 * 注册Activity
 * <p>
 * Created by 深圳唐龙飞讯科技有限公司 on 2018/6/7.
 */
public class RegisterActivity extends BaseActivity<ActivityRegisterBinding, RegisterViewModel> {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addStatusBar();
    }

    @Override
    public void addStatusBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //透明状态栏
            View decorView = getWindow().getDecorView();
            //让应用主题内容占用系统状态栏的空间,注意:下面两个参数必须一起使用 stable 牢固的
            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            decorView.setSystemUiVisibility(option);
            //设置状态栏颜色为透明
            getWindow().setStatusBarColor(Color.TRANSPARENT);
        }
    }

    @Override
    public int setLayout() {
        return R.layout.activity_register;
    }

    @Override
    public void init() {
        String nickname = getIntent().getStringExtra("nickname");
        String figureurl = getIntent().getStringExtra("figureurl");
        String openId = getIntent().getStringExtra("openId");
        LogUtil.e("openId " + openId + " nickname " + nickname + " figureurl  " + figureurl);
        if (!Check.isEmpty(openId)) {
            mViewModel.openId.set(openId);
        }
        if (!Check.isEmpty(figureurl)) {
            mViewModel.figureurl.set(figureurl);
        }
        if (!Check.isEmpty(nickname)) {
            mViewModel.nickname.set(nickname);
        }
    }

    @Override
    public Class createViewModel() {
        return RegisterViewModel.class;
    }

    @Override
    public void loadData() {
        toFragment(R.id.fl_content, new RegisterFragment());
    }
}
